package com.pro.utils;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName: guava缓存工具类
 * @Description: TODO
 * @Author: 李振海1
 * @Date 2021/7/28 12:48
 */
@Component
public class GuavaUtils {
    //缓存对象
    private static Cache<String,Object> tenCacheBuild= CacheBuilder.newBuilder()
            //初始化容量
            .initialCapacity(5)
            //容量最大值
            .maximumSize(100)
            //设置并发数
            .concurrencyLevel(5)
            //设置缓存的过期时间
            .expireAfterWrite(600, TimeUnit.SECONDS)
            //缓存项在给定时间内没有被读/写访问，则回收
            .recordStats()
            .build();

    public static Cache<String, Object> getTenCacheBuild() {
        return tenCacheBuild;
    }

    public void setTenCacheBuild(Cache<String, Object> tenCacheBuild) {
        this.tenCacheBuild = tenCacheBuild;
    }



}